
{extend name=".././view/list.html" /}
{block name="jsset"}
{load href="__STATIC__/echarts/echarts.js" /}
{load href="__STATIC__/echarts/infographic.js" /}
{/block}
{block name="nav"}
<span class="layui-breadcrumb">
	<a href="">成绩查询</a>
	<a><cite>班级成绩</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item">
  <label for="xueqi_id" class="layui-form-label" style="height: 100%">学期</label>
  <div class="layui-input-block">
    <input type="radio" name="xueqi_id" title="无" value="" lay-skin="primary" checked="checked">
    {php} $category = categoryChildren(108);{/php}
    {volist name="category" id="vo"}
    <input type="radio" name="xueqi_id" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
    {/volist}
  </div>
</div>
<div class="layui-form-item">
  <label for="category_id" class="layui-form-label" style="height: 100%">考试类型</label>
  <div class="layui-input-block">
    {php} $category = categoryChildren(109);{/php}
    {volist name="category" id="vo"}
    <input type="checkbox" name="category_id[]" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
    {/volist}
  </div>
</div>
<div class="layui-form-item">
  <label for="subject_id" class="layui-form-label" style="height: 100%">学科</label>
  <div class="layui-input-block">
    {volist name="list.subject" id="vo"}
    <input type="checkbox" name="subject_id[]" title="{$vo.title}" value="{$vo.id}" lay-skin="primary">
    {/volist}
  </div>
</div>
<div class="layui-form-item">
  <div class="layui-inline">
    <label for="title" class="layui-form-label">
      考试时间
    </label>
    <div class="layui-input-inline">
      <input type="text" class="layui-input" id="bfdate" name="bfdate" placeholder="起始：默认二年前的今天" value="{$list.data.bfdate|default=''}" autocomplete="off" lay-filter="riqi">
    </div>
    <div class="layui-input-inline">
      <input type="text" class="layui-input" id="enddate" name="enddate" placeholder="结束：默认明天" value="{$list.data.enddate|default=''}" autocomplete="off" lay-filter="riqi">
    </div>
  </div>
</div>
<input type="hidden" name="teacher_id" value="{$list.teacher_id}">
{/block}
{block name="table"}
  <table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="echart"}
<!-- <div class="layui-row" style="padding-top: 80px;"> -->

  <!-- </div> -->
{/block}
{block name="myjs"}
  <!-- 表格上面按钮模板 -->
  <script type="text/html" id="toolbarDemo">
   <div class="layui-btn-container">
		<button class="layui-btn" lay-event="download">
			<i class="layui-icon layui-icon-download-circle"></i> 下载
		</button>
	</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<a class="layui-btn-xs" lay-event="detail" title="查看学生成绩"><i class="layui-icon">&#xe62d;</i></a>
</script>
<!-- 表格操作 -->
<script>
	// 设置列
  	options.cols=[[ //表头
    	{type:'numbers', title:'序号', fixed:true, minWidth:10},
      {field: 'id', title: '操作', toolbar: '#barDemo', minWidth:10, fixed:true},
    	{field: 'banji_id', title: '班级',sort: true, minWidth:140, fixed:true, templet:function(d){
        var str = d.banjiTitle;
        return str;
      }},
      {field: 'kaoshi_id', title: '考试',sort: true, minWidth:200, fixed:true,templet:function(d){
        var str='';
        if(d.bjKaoshi )
        {
          str = d.bjKaoshi.title;
        }
        return str;
      }},
      {field: 'subject_id', title: '学科',sort: true, templet:function(d){
        var str = '';
        if(d.bjSubject)
        {
          str = d.bjSubject.title;
        }
        return str;
      }},
      {field: 'chengji_cnt', title: '人数',sort: true},
      {field: 'avg', title: '平均分',sort: true},
      {field: 'jige', title: '及格率%',sort: true},
      {field: 'youxiu', title: '优秀率%',sort: true},
      {field: 'biaozhuncha', title: '标准差',sort: true},
      {field: 'max', title: '最高分',sort: true},
      {field: 'min', title: '最低分',sort: true},
      {field: 'zhongweishu', title: '中位数',sort: true},
      {field: 'zhongshu', title: '众数',sort: true},
    ]
    ];

  // 提交搜索条件后重载表格
  layui.use(['table','cjgl','laydate'],function(){
  	var table = layui.table
  	cjgl = layui.cjgl
    laydate = layui.laydate
  	form = layui.form;

    // 添加班级
    // addBanji();
    // loadTubiao()
    //表头工具栏事件
    table.on('toolbar(mytable)', function(obj){
      switch(obj.event){
        case 'dels':
          break;
	        var checkStatus = table.checkStatus('mytable'); //idmytable 即为基础参数 id 对应的值
	        cjgl.delAll(checkStatus,'/school','mytable');
	        break;
	      case 'add':
	        cjgl.add('添加单位','/school/create','650','500');
	        break;
	      case 'download':
          layer.msg('看看就行啦 ^_^');
          break;
	        cjgl.add('下载成绩','/chengji/bjtj/dwbiaoge/' + "{$list.teacher_id}",'650','300');
	        break;
       };
     });

    //监听行工具条
    table.on('tool(mytable)', function(obj){
        var data = obj.data; //获得当前行数据
        var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
        var tr = obj.tr; //获得当前行 tr 的DOM对象
        switch(layEvent){
        	case 'detail':// 查看
            cjgl.addTab('查看学生成绩', '/teachersearchchengji/index/detail/' + data.id, true);
            break;
        	case 'del':// 删除
            cjgl.del(obj,"/school");
            break;
        	case 'edit':// 编辑
            cjgl.add('编辑单位','/school/edit','650','500');
            break;
        	case 'status':// 状态
            cjgl.status(obj,"{:url('setstatus')}");
            break;
        };
      });

    //开始时间
    laydate.render({
      elem: '#bfdate'
      ,type: 'datetime'
      ,trigger: 'click' //采用click弹出
      ,format: 'yyyy-M-d' //可任意组合
      ,done: function(value, date, endDate){
        form.val("search",{
          "bfdate" : value,
        });
        $("#srcsubmit").click();
      }
    });
    //结束时间
    laydate.render({
      elem: '#enddate'
      ,type: 'datetime'
      ,trigger: 'click' //采用click弹出
      ,format: 'yyyy-M-d' //可任意组合
      ,done: function(value, date, endDate){
        form.val("search",{
          "enddate" : value,
        });
        $("#srcsubmit").click();
      }
    });

  });

 </script>
 {/block}
